<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加任务</title>
    <style>
        .two-part-label{
            width: 200px !important;
        }
    </style>
</head>
<body>
<script type="text/html" id="form">
<!--<form class="layui-form" lay-filter="layui-form">-->
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text style="color:red;">*</text>
                    任务名称</label>
                <div class="layui-input-block">
                    <input type="text" name="task_name" placeholder="请输入任务名称" class="layui-input" lay-verify="required"
                           autocomplete="off" value="{{ d.task_name }}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" title="日期">日期</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input"
                           name="date" id="date" data-type="date"
                           autocomplete="off" placeholder="请选择日期" lay-verify="" />
                </div>
            </div>

            <blockquote class="layui-elem-quote">今日季节蜡烛</blockquote>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text style="color:red;">*</text>
                    位置</label>
                <div class="layui-input-block">
                    <input type="text" name="season_candle_location" placeholder="请输入今日季节蜡烛位置" class="layui-input" lay-verify="required"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><text style="color:red;">*</text>图示</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="season_candle_image"
                         data-accept="image"
                         data-type="ali-oss"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>

            <blockquote class="layui-elem-quote">今日大蜡烛</blockquote>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text style="color:red;">*</text>
                    位置</label>
                <div class="layui-input-block">
                    <input type="text" name="big_candle_location" placeholder="请输入今日大蜡烛位置" class="layui-input" lay-verify="required"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><text style="color:red;">*</text>图示</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="big_candle_image"
                         data-accept="image"
                         data-type="ali-oss"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>

            <blockquote class="layui-elem-quote">今日任务</blockquote>

            <div class="layui-form-item">
                <label class="layui-form-label">任务1</label>
                <div class="layui-input-block">
                    <input type="text" name="task_name1" placeholder="请输入今日任务1" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">描述1</label>
                <div class="layui-input-block">
                    <input type="text" name="task_description1" placeholder="请输入今日任描述1" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图示1</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="task_image1"
                         data-accept="image"
                         data-type="ali-oss"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">任务2</label>
                <div class="layui-input-block">
                    <input type="text" name="task_name2" placeholder="任务2" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">描述2</label>
                <div class="layui-input-block">
                    <input type="text" name="task_description2" placeholder="描述2" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图示2</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="task_image2"
                         data-accept="image"
                         data-type="ali-oss"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">任务3</label>
                <div class="layui-input-block">
                    <input type="text" name="task_name3" placeholder="请输入今日任务3" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">描述3</label>
                <div class="layui-input-block">
                    <input type="text" name="task_description3" placeholder="请输入今日任描述3" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图示3</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="task_image3"
                         data-accept="image"
                         data-type="ali-oss"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">任务4</label>
                <div class="layui-input-block">
                    <input type="text" name="task_name4" placeholder="请输入今日任务4" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">描述4</label>
                <div class="layui-input-block">
                    <input type="text" name="task_description4" placeholder="请输入今日任描述4" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图示4</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="task_image4"
                         data-accept="image"
                         data-type="ali-oss"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">任务5</label>
                <div class="layui-input-block">
                    <input type="text" name="task_name5" placeholder="请输入今日任务5" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">描述5</label>
                <div class="layui-input-block">
                    <input type="text" name="task_description5" placeholder="请输入今日任描述5" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图示5</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="task_image5"
                         data-accept="image"
                         data-type="ali-oss"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">任务6</label>
                <div class="layui-input-block">
                    <input type="text" name="task_name6" placeholder="请输入今日任务6" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">描述6</label>
                <div class="layui-input-block">
                    <input type="text" name="task_description6" placeholder="请输入今日任描述6" class="layui-input"
                           autocomplete="off" value="">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图示6</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="task_image6"
                         data-accept="image"
                         data-type="ali-oss"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>

        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
<!--</form>-->
</script>
<form class="layui-form" lay-filter="layui-form"></form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>

</script>
<script>
    layui.use(['laytp','xmSelect','form', 'laydate'], function () {

        let form = layui.form;
        let laydate = layui.laydate;
        let attr = {
            'date':'',
            'icon':'',
            'task_img':'',
            'sort':'',
            'status':'',
            'target':'',
            'target_season':'',
            'task_desc':'',
            'task_id':'',
            'task_name':'',
        };
        //日期
        var myDate =  new Date();  //获取当前时间
        var d = myDate.getDate();
        if(d<10){
            d = "0"+d;
        }
        renderHtml();
        function renderHtml(){
            layui.laytpl($("#form").html()).render(attr,function(string){
                $("form").html(string);
                layui.laytpForm.render();
                form.render();
                laydate.render({
                    elem: '#date'
                    ,value:attr.date
                    ,min:myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+d
                    ,done: function (value){
                        attr.date = value;
                    }
                });
            });
        }
        window.xmcb = function (params){
            params['arr'][0]['task_id'] = params['arr'][0]['id'];
            for (let key in attr){
                if(typeof params['arr'][0][key] != "undefined"){
                    attr[key] = params['arr'][0][key]
                }
            }
            renderHtml();
        }
        layui.form.on('submit(add)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.sky.task/add',
                data : data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.funController.tableRender();
                    parent.parent.renderMenu();//重新渲染菜单
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    });

</script>
</body>
</html>